//
//  ViewController.m
//  Drawboard
//
//  Created by Mac on 2020/6/21.
//  Copyright © 2020 Mac. All rights reserved.
//

#import "ViewController.h"
#import "ImitateViewController.h"
#import "ChoosePictureViewController.h"
#import "MyCreationViewController.h"

@interface ViewController ()

@property (nonatomic, weak)UIImageView * backView;
@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, strong)UIButton * imitateButton;
@property (nonatomic, strong)UIButton * originalButton;
@property (nonatomic, strong)UIButton * myCreateButton;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupUI];
}


- (void)setupUI{
    
    UIImageView * backView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    
    backView.image = [UIImage imageNamed:@""];
    
    self.backView = backView;
    
    [self.view addSubview:self.backView];
    
    
    UILabel * titleLabel = [[UILabel alloc] init];
    
    titleLabel.text = @"Little Animal Painter";
    titleLabel.textColor = ZRWhiteColor;
    titleLabel.font = [UIFont boldSystemFontOfSize:32];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.centerY = self.view.centerY;
    
    self.titleLabel = titleLabel;
    
    [self.view addSubview:self.titleLabel];
    
    self.imitateButton = [self setupButtonWithImg:@"imitata"];
    [self.view addSubview:self.imitateButton];
    self.originalButton = [self setupButtonWithImg:@"original"];
    [self.view addSubview:self.originalButton];
    self.myCreateButton = [self setupButtonWithImg:@"my_create"];
    [self.view addSubview:self.myCreateButton];
}


- (void)clickHomeButton:(UIButton *)btn{
    
    if (btn == self.imitateButton) {
        
        ChoosePictureViewController * chooseVC = [ChoosePictureViewController new];
        chooseVC.comeFrom = @"1";
        [self.navigationController pushViewController:chooseVC animated:YES];
    }else if (btn == self.originalButton){
        
        ImitateViewController * imitateVC = [ImitateViewController new];
        
        [self.navigationController pushViewController:imitateVC animated:YES];
    }else{
        
        MyCreationViewController * myVC = [MyCreationViewController new];
        
        [self.navigationController pushViewController:myVC animated:YES];
    }
}

- (void)viewDidLayoutSubviews{
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(60);
        make.height.mas_equalTo(45);
    }];
    
    [self.originalButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(44);
        make.height.width.mas_equalTo(172);
    }];
    
    [self.imitateButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.originalButton.mas_leading).offset(-12);
        make.height.width.centerY.mas_equalTo(self.originalButton);
    }];
    
    [self.myCreateButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.originalButton.mas_trailing).offset(12);
        make.height.width.centerY.mas_equalTo(self.originalButton);
    }];
}


-(UIButton *)setupButtonWithImg:(NSString *)img{
    
    UIButton * button = [UIButton new];
    
    [button setImage:[UIImage imageNamed:img] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(clickHomeButton:) forControlEvents:UIControlEventTouchUpInside];
    
    return button;
}



@end
